home *** CD-ROM | disk | FTP | other *** search
-
- LISTING 2
- /*
- main.c - main program for time stamp testing
-
- Written by: Charles B. Allison
- Allison Technical Services
- Houston, Texas, USA 77036
- */
-
- #include <stdio.h>
- #include <conio.h>
- void main(void);
- extern long get_time(void);/* get 32 bit time value */
- extern int get_tmr(void); /* get timer contents */
- extern void init_timer(void);/*set 8253 timer mode=2*/
- extern long get_sec_time(long val);/*since midnight */
- /* get milliseconds since last full second */
- extern int get_msec_time(long val);
- /* get absolute difference in two 32 bit
- time stamp values */
- extern long atime_diff(unsigned long time1,
- unsigned long time2);
- /* print the time hh:mm:ss.ffff */
- extern void print_time(unsigned long intim);
-
- /* ---------------- main --------------- */
- void main(void)
- {
- long time1, time2, diff;
-
- init_timer(); /* change timer to mode 2 */
- time1 = get_time();
- printf("Program beginning at time: ");
- print_time(time1);
- printf("\n");
- time1 = get_time();
- printf("How long does it take to output This message?\n");
- time2 = get_time();
- diff = atime_diff(time1,time2);
- printf("\nIt takes ");
- print_time(diff);
- printf(" to print out that message.\n\n");
- printf("Press the Enter key to exit\n");
- getch();
- time1 = get_time();
- printf("\nProgram exiting at time = ");
- print_time(time1);
- printf("\n");
- }
-